import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/personalSettings/model/list_title_bean.dart';
import 'package:boss/ui/page/reportForm/billSummary/bill_summary_page.dart';
import 'package:boss/ui/page/reportForm/clerkCashier/clerk_cashier.dart';
import 'package:boss/ui/page/reportForm/collectionStatistics/collection_statistics.dart';
import 'package:boss/ui/page/reportForm/order/order_page.dart';
import 'package:boss/ui/page/reportForm/profitForm/profit_form.dart';
import 'package:boss/ui/page/reportForm/reportTableQr/report_table_qr_page.dart';
import 'package:boss/ui/page/reportForm/sensitiveOperation/sensitive_operation.dart';
import 'package:boss/ui/page/reportForm/vegetablesStatistics/vegetables_statistics.dart';
import 'package:boss/ui/widget/image/base_image.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:router/annotation.dart';

@RouterConfig(ReportPage.pageName)
class ReportPage extends StatefulWidget {
  static const String pageName = '/reportPage';

  @override
  _ReportPageState createState() => _ReportPageState('报表');
}

class _ReportPageState extends BaseState<ReportPage> {
  _ReportPageState(String pageName) : super(pageName);

  List<ListTitleBean> items = [
    ListTitleBean(
      title: '账单汇总',
      icon: 'assets/image/report_bill.png',
      url: BillSummaryPage.pageName,
    ),
    ListTitleBean(
      title: '订单明细',
      icon: 'assets/image/report_order.png',
      url: OrderPage.pageName,
    ),
    ListTitleBean(
      title: '敏感操作',
      icon: 'assets/image/report_ sensitive.png',
      url: SensitiveOperationPage.pageName,
    ),
    ListTitleBean(
      icon: 'assets/image/report_ commission.png',
      title: '提成报表',
      url: ProfitFormPage.pageName,
    ),
    ListTitleBean(
      icon: 'assets/image/report_cash.png',
      title: '店员收银',
      url: ClerkCashierPage.pageName,
    ),
    ListTitleBean(
      icon: 'assets/image/report_ operating.png',
      title: '运营分析',
      url: ChannelStatisticsPage.pageName,
    ),
    ListTitleBean(
      icon: 'assets/image/report_commodity.png',
      title: '菜品统计',
      url: VegetablesStatisticsPage.pageName,
    ),
    ListTitleBean(
      icon: 'assets/image/report_table_qr.png',
      title: '台卡收款统计',
      url: ReportTableQrPage.pageName,
    ),
  ];

  @override
  Widget build(BuildContext context) {
    final safeTop = MediaQuery.of(context).padding.top;

    return Scaffold(
      body: Container(
        height: double.infinity,
        child: Stack(
          alignment: Alignment.topCenter,
          children: [
            Container(
              width: double.infinity,
              height: 310.w + safeTop,
              padding: EdgeInsets.only(top: safeTop),
              decoration: BoxDecoration(
                image: DecorationImage(
                  fit: BoxFit.fitHeight,
                  image: AssetImage('assets/image/report_header_bg.png'),
                ),
              ),
              alignment: Alignment.topCenter,
              child: Container(
                height: 88.w,
                alignment: Alignment.center,
                child: Text(
                  '报表中心',
                  style: TextStyleConstant().white_36.copyWith(fontWeight: FontWeight.bold),
                ),
              ),
            ),
            Positioned.fill(
              top: 250.w + safeTop,
              left: 20.w,
              right: 20.w,
              bottom: 0,
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(14),
                ),
                child: GridView.builder(
                  padding: EdgeInsets.symmetric(vertical: 40.w, horizontal: 20.w),
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
                  itemBuilder: (context, index) {
                    return buildItem(items[index]);
                  },
                  itemCount: items.length,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget buildItem(ListTitleBean item) {
    return GestureDetector(
      onTap: () {
        Navigator.pushNamed(context, item.url);
      },
      child: Column(
        children: [
          BaseImage(item.icon, width: 100.w, height: 100.w),
          Container(
            child: Text(item.title, style: TextStyleConstant().normal_1_22),
            margin: EdgeInsets.only(top: 10.w),
          ),
        ],
      ),
    );
  }
}
